/*
 * @(#)TestFireRequestHandler.java
 *
 *
 *
 * ver 1.0 Aug 30, 2007 ggranum
 */
package org.testfire.agent.handlers;

import org.testfire.agent.AgentProperties;
import org.testfire.agent.runner.TestSetRunner;
import org.testfire.agent.httpserver.Request;
import org.testfire.agent.httpserver.RequestHandler;
import org.testfire.agent.httpserver.Response;

public class TestFireRequestHandler implements RequestHandler
{
    private final AgentProperties agentProps;

    public TestFireRequestHandler( AgentProperties agentProps )
    {
        this.agentProps = agentProps;
    }

    public synchronized void handleRequest( Request request, Response response )
    {
//        TestSetRunner r;
//        try
//        {
//            r = new TestSetRunner( this.agentProps, request );
//            response.putParameter( "response", "0" );
//        }
//        catch ( Exception e )
//        {
//            response.setError( e );
//            response.putParameter( "response", "-1" );
//            return;
//        }
//        r.start();
//        hiDone();
    }

    public boolean shouldHandleRequest( Request request )
    {
        return request.getUrl().endsWith( "testset.run" );
    }

    public synchronized void hiDone( )
    {
        this.notify();
    }

    public AgentProperties getAgentProperties()
    {
        return agentProps;
    }
}

// eof: TestFireRequestHandler.java